CC ?= gcc

ifeq ($(CC),arm-linux-gcc)
CFLAGS=-Wall -O2 -DLINUX -D_GNU_SOURCE -fPIC -I/opt/FriendlyARM/jpeg/include
CFLAGS_D=-Wall -g -DLINUX -D_GNU_SOURCE -fPIC -I/opt/FriendlyARM/jpeg/include
LDFLAGS= -lpthread -L/opt/FriendlyARM/jpeg/lib -ljpeg -fpic
LDFLAGS_D= -lpthread -L/opt/FriendlyARM/jpeg/lib -ljpeg -fPIC
else
CFLAGS=-Wall -O2 -DLINUX -D_GNU_SOURCE -fPIC
CFLAGS_D=-Wall -g -DLINUX -D_GNU_SOURCE -fPIC
LDFLAGS= -lpthread -ljpeg -fpic
LDFLAGS_D= -lpthread -ljpeg -fpic
endif

INPUT_OBJECT= input_yuyv.o yuyv_jpeg.o 

TARGET=libinput_yuyv.so
TARGET_D=libinput_yuyv_d.so


INPUT_OBJECT_D=input_yuyv_d.o yuyv_jpeg_d.o


all:$(TARGET)

$(TARGET):$(INPUT_OBJECT)
	$(CC) $(CFLAGS) $(LDFLAGS) $(INPUT_OBJECT) -shared -o $@

input_yuyv.o:input_yuyv.c input_yuyv.h
	$(CC) $(CFLAGS) $< -c -o $@

yuyv_jpeg.o: yuyv_jpeg.c yuyv_jpeg.h
	$(CC) $(CFLAGS) $< -c -o $@

clean:
	rm -f *.o *~ capture *.so

debug:$(TARGET_D)

$(TARGET_D):$(INPUT_OBJECT_D)
	$(CC) $(CFLAGS_D) $(LDFLAGS_D) $(INPUT_OBJECT_D) -shared -o $@

input_yuyv_d.o:input_yuyv.c input_yuyv.h
	$(CC) $(CFLAGS_D) $< -c -o $@

yuyv_jpeg_d.o:yuyv_jpeg.c yuyv_jpeg.h
	$(CC) $(CFLAGS_D) $< -c -o $@

.PHONY: all clean debug
